<style type="text/css">
.fui-cellone {
    position: relative;
    padding: 0.3rem 0.5rem;
	-webkit-align-items: flex-start;
	align-items:flex-start;
}
.fui-cellone .fui-cellone-label,.fui-cellone .fui-cellone-remark {
    width: 2.6rem;
}
.fui-cellone .fui-cellone-text .text{
    background: #fff;
    border-radius: 0.3rem;
	padding:0.3rem 0.4rem;
	font-size:0.7rem;
    color: #333;
    width: auto;
}
.fui-cellone-remark .pic{float: right;width: 2rem;height: 2rem;border-radius: 0.2rem; margin-left:0.5rem;}
.fui-cellone-label .pic{float: left;width: 2rem;height: 2rem;border-radius: 0.2rem;margin-right: 0.5rem;}
.logtime{position:relative;text-align:center;font-size: 0.7rem;line-height:2;width:7.6rem;margin: 0.6rem auto 0;color: #666;border-radius: 0.2rem;}
body,html,#mainpage,#sendbox{width: 100%;height: 100%;background:none;}
#sendbox {-webkit-box-orient: vertical;-webkit-flex-direction: column;-moz-flex-direction: column;-ms-flex-direction: column;-o-flex-direction: column;flex-direction: column;}
#sendbox .chat-main{-webkit-box-flex: 1;-moz-box-flex: 1;-webkit-flex: 1;-ms-flex: 1;flex: 1;width: 100%;font-size: 0.65rem;overflow-x: hidden;-webkit-overflow-scrolling: touch;background: none;display: block;}
#sendbox .chat-main .chatlog(padding: 0.2rem;width:100%)
#sendbox .r .text{float: right;}
#sendbox .l .text{float: left;}
#chat-foot{height: 2.5rem;background: #fff;width: 100%;border-top: #EBEBEB solid 1px;padding: 0.4rem 0.2rem;z-index:11}
#chat-foot span {line-height:1.3rem;font-size:1.4rem;}
#chat-foot .inp{float: left; display: block;color: #333;text-indent: 0.6rem;line-height:1.4rem}
#chat-foot input{border:none;}
#chat-foot .sub-btn{width:2.5rem;text-align:center;float: right;background: #18bc9c;color: #fff;border-radius: 0.2rem;margin:0 0.1rem 0.2rem 0}
#chat-foot .showaudio{text-align:center;}
.chat-audio {position: fixed;z-index: 12;left: 30%;width:40%;top: 30%;font-size: 0.65rem;color: #fff;background: #000;opacity: 0.7;border-radius: 0.15rem;text-align:center;padding:0.2rem;}
.chat-audio .recording{font-size:2rem;height:0.7rem;}
.fui-content {
	position: absolute;
	display: block;
	width: 100%;
	height:100%!important; 
	overflow: auto;
	-webkit-overflow-scrolling: touch;
	padding-bottom:0
}
.chatlog {
	min-height:100%!important; 
	display: box;
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-flex-direction: row;
    -moz-flex-direction: row;
    -ms-flex-direction: row;
    -o-flex-direction: row;
    flex-direction: column-reverse;
}
.fui-cell {
	position: relative;
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-align: center;
	-webkit-align-items: center;
	-ms-flex-align: center;
	align-items: center;
	-moz-transition-duration: 300ms;
	-webkit-transition-duration: 300ms;
	transition-duration: 300ms;
	-webkit-transition-property: background-color;
	transition-property: background-color;
	line-height: 1;
}
.fui-cell .text{font-size:0.8rem;line-height:1.2rem}
.fui-cell .icon{font-size:1.6rem}
.fui-cell-group .fui-cell {line-height:1.7;height:1.6rem}
.background{
	background: url('../addons/jy_yiliao/resource/images/liaobg.jpg')  no-repeat 50%;background-size: cover;
}
.background::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: url('../addons/jy_yiliao/resource/images/liaobg.jpg')  no-repeat 50%;background-size: cover;
  filter: blur(10px);
}
.arrow-left {
  position: absolute;
  left:2.4rem;
  top:0.4rem;
  width:0px;
  height:0px;
  border-bottom:5px solid transparent;  /* left arrow slant */
  border-top:5px solid transparent; /* right arrow slant */
  border-right:5px solid #fff; /* bottom, add background color here */
  font-size:0px;
  line-height:0px;
  margin-bottom:-1px
}
.arrow-right {
  position: absolute;
  right:3.1rem;
  top:0.6rem;
  width:0px;
  height:0px;
  border-bottom:5px solid transparent;  /* left arrow slant */
  border-top:5px solid transparent; /* right arrow slant */
  border-left:5px solid #c07bf2; /* bottom, add background color here */
  font-size:0px;
  line-height:0px;
  margin-bottom:-1px
}
.fui-icon-group.col-6 .fui-icon-col-sm {
    width: 16.66%;
}
</style>
<div class="fui-page" style="z-index: 10;">
<div class="fui-content background" style="max-width:680px;margin:auto;">
<div style="padding:0.7rem;position: absolute;top:0;width:100%;z-index:1000">
				<div class="radius" style="padding:0.5rem;background: url('../addons/jy_yiliao/resource/images/liaobg.jpg') no-repeat 50%;background-size: cover;">
					<div class="fui-cellone" style="align-items: center;padding:0">
						<div class="fui-cellone-label" style="width:auto;padding-right:0.5rem">
							<i class="icon icon-dingdan" style="font-size:0.65rem;color:#c179ff"/></i>
						</div>
						<div class="fui-cellone-text" style="font-size:0.65rem;color:#666">
							大夫姓名：{{pagedata.worker.username||'无'}}
						</div>
					</div>
					<div class="fui-cellone" style="align-items: center;padding:0">
						<div class="fui-cellone-label" style="width:auto;padding-right:0.5rem">
							<i class="icon icon-map" style="font-size:0.65rem;color:#c179ff"/></i>
						</div>
						<div class="fui-cellone-text" style="font-size:0.65rem;color:#666">
							所在医院：{{pagedata.worker.storetitle||'无'}}
						</div>
					</div>
					<div class="fui-cellone" style="align-items: center;padding:0">
						<div class="fui-cellone-label" style="width:auto;padding-right:0.5rem">
							<i class="icon icon-map" style="font-size:0.65rem;color:#c179ff"/></i>
						</div>
						<div class="fui-cellone-text" style="font-size:0.65rem;color:#666">
							所在科室：{{pagedata.worker.lessontitle||'无'}}
						</div>
					</div>
					<div class="fui-cellone" style="align-items: center;padding:0">
						<div class="fui-cellone-label" style="width:auto;padding-right:0.5rem">
							<i class="icon icon-gerenrenzheng1" style="font-size:0.65rem;color:#c179ff"/></i>
						</div>
						<div class="fui-cellone-text" style="color:#999">
							<span class="label label-gray radius" style="border-radius:1rem;padding:0.3rem 0.5rem;background:#e8fcf3;color:#5cd1a4">已真人认证</span>
							<span class="label label-gray radius" style="border-radius:1rem;padding:0.3rem 0.5rem;background:#f5ecfd;color:#c77afe">已实名认证</span>
						</div>
					</div>
				</div>
</div>
<div id="sendbox" class="flex" style="padding-top:6.6rem;">
	<div class="chat-main flex" id="svposttext" style="padding-bottom:2rem">
		<div ng-show="pagedata.loading" class='infinite-loading'><span class='fui-preloader'></span><span style="margin-left:1.5rem"> 正在加载...</span></div>
		<div class="chatlog" style="padding-top:0.5rem;">
			<div ng-include="sys_html('online/_listnew')"></div>
			<div ng-if="pagedata.goods.id" style="padding:0.5rem">
				<div class="radius" style="background:#fff;padding:0.5rem">
					<div class="fui-cellone" style="align-items: center;padding:0">
						<div class="fui-cellone-label" style="width:auto;padding-right:0.5rem">
							<img style="border-radius: 0.2rem;width:4rem;height:4rem;" ng-src="{{tomedia(pagedata.goods.image) || '../core/resource/images/nopic.jpg'}}" />
						</div>
						<div class="fui-cellone-text">
							<div class="overflow-h2" style="">{{pagedata.goods.title}}</div>
							<div class="bold" style="font-size:0.8rem;padding-top:0.3rem">￥{{pagedata.goods.price}}</div>
						</div>
					</div>
					<div class="c" style="margin-top:0.5rem;border-top:#999 1px dashed;padding-top:0.5rem">
						<span class="btn btn-sm btn-success-o" ng-click="pagedata.post.goodsid=pagedata.goods.id;pagedata.addchatnew(8);" style="border-radius: 1rem;">发送链接</span>
					</div>
				</div>
			</div>
			<div ng-repeat="item in pagedata.list">
						<div ng-if="item.createtime" class="logtime">{{item.createtime}}</div>
						<div ng-if="item.isworker!=1" class="fui-cellone">
						<div class="fui-cellone-label"></div>
						<div class="fui-cellone-text">
							<div ng-include="sys_html('online/_msgtype')"></div>
						</div>
						<div class="fui-cellone-remark noremark">
							<div class="arrow-right" style="{{item.type>0&&item.type!=3&&item.type!=9?'border-left:5px solid #fff':''}}"></div>
							<img class="pic" mode="widthFix" style="background: url('{{pagedata.member.avatar || '../core/resource/images/gw-wx.png'}}') no-repeat;background-size: 100% 100%;"/>
						</div>
						</div>
						<div ng-if="item.isworker==1" class="fui-cellone">
						<div class="fui-cellone-label">
							<img class="pic" mode="widthFix" style="background: url('{{pagedata.worker.avatar || '../addons/jy_yiliao/resource/images/avatar.png'}}') no-repeat;background-size: 100% 100%;"/>
							<div class="arrow-left"></div>
						</div>
						<div class="fui-cellone-text">
							<div ng-include="sys_html('online/_msgtype2')"></div>
						</div>
						<div class="fui-cellone-remark noremark" style="text-align: left;">
							<i ng-if="item.type==0" ng-click="tool.clip(item.msg)" class="icon icon-copy" style="font-size:0.8rem;padding:0.2rem;border-radius:0.2rem"></i>
						</div>
						</div>
			</div>
		</div>
	</div>
	<div id="chat-foot" class="flex" style="height:auto;padding-bottom:0;">
			<div class="fui-cell-group" style="padding:0;width:100%;margin-top:0">
				<div class="fui-cellone" style="padding:0 0.5rem;">
					<div class="fui-cellone-info">
						<div class="fui-cellone" style="align-items: center;padding:0">
							<div class="fui-cellone-icon" style="width:auto;height:1.2rem;line-height:1.2rem;margin-right:0.5rem">
							<span ng-if="!pagedata.showtoaudio" href="javascript:;" ng-click="pagedata.showtoaudio=true" class="icon icon-seeraudio" style="width:1.6rem"></span>
							<span ng-if="pagedata.showtoaudio" href="javascript:;" ng-click="pagedata.showtoaudio=false" class="icon icon-keyboard" style="font-size:1.55rem;width:1.6rem"></span>
							</div>							
							<div class="fui-cellone-info" style="background: #F5F5F7;border-radius:1rem;padding:0.15rem;">
							<input ng-if="!pagedata.showtoaudio" class="inp" style="width:100%;background: #F5F5F7;" type="text" ng-model="pagedata.post.msg" placeholder="请输入想说的话..."></input>
							<div class="showaudio {{!pagedata.showtoaudio?'hide':''}}" style="font-size:0.8rem;line-height: 1.4rem;-moz-user-select: none; -khtml-user-select: none; user-select: none;">
								{{pagedata.showluyin?'松开  结束':'按住 说话'}}
							</div>
							</div>
						</div>
					</div>
					<div ng-if="pagedata.post.msg" class="fui-cellone-remark noremark" style="margin-left:0.5rem;width:auto;margin-right:0.55rem;padding-top:0.1rem">
							<i id="searchsub" class="icon" ng-click="pagedata.addchatnew()"><img class="icon" style="width:3.1rem;" src="../addons/jy_yiliao/resource/images/fasong.png"/></i>

					</div>
				</div>
				<div class="fui-icon-group noborder col-6" style="padding:10px 2px;">
					<div class="fui-icon-col-sm external" style="margin:0" href="javascript:;" ng-click="access_json('jy_yiliao/online.log/');">
						<div class="c radius" style="width:2.5rem;height:1.5rem;line-height:1.5rem;margin:auto">
							<img class="icon" style="width:1.2rem;" src="../addons/jy_yiliao/resource/images/fanhui.png"/>
						</div>
					</div>
					<div class="fui-icon-col-sm external" style="margin:0" href="javascript:;" ng-click="pagedata.showtoaudio=true">
						<div class="c radius" style="width:2.5rem;height:1.5rem;line-height:1.5rem;margin:auto">
							<img class="icon" style="width:1.2rem;" src="../addons/jy_yiliao/resource/images/audio.png"/>
						</div>
					</div>
					<div ng-if="pagedata.pluginset.videocall_open==1" class="fui-icon-col-sm external" style="margin:0" href="javascript:;" ng-click="pagedata.showshiping=true;pagedata.toshiping()">
						<div class="c radius" style="width:2.5rem;height:1.5rem;line-height:1.5rem;margin:auto">
							<img class="icon" style="width:1.2rem;" src="../addons/jy_yiliao/resource/images/shiping.png"/>
						</div>
					</div>
					<div class="fui-icon-col-sm external" style="margin:0" href="javascript:;" ng-click="pagedata.uppic();">
						<div class="c radius" style="width:2.5rem;height:1.5rem;line-height:1.5rem;margin:auto">
							<img class="icon" style="width:1.2rem;" src="../addons/jy_yiliao/resource/images/img.png"/>
						</div>
					</div>
					<div class="fui-icon-col-sm external" style="margin:0" href="javascript:;" ng-click="pagedata.showemoji=true;">
						<div class="c radius" style="width:2.5rem;height:1.5rem;line-height:1.5rem;margin:auto">
							<img class="icon" style="width:1.2rem;" src="../addons/jy_yiliao/resource/images/biaoqing.png"/>
						</div>
					</div>
					<div class="fui-icon-col-sm external" style="margin:0" href="javascript:;" ng-click="pagedata.showmore=true">
						<div class="c radius" style="width:2.5rem;height:1.5rem;line-height:1.5rem;margin:auto">
							<i class="icon icon-jia" style="font-size:1.1rem;color:#707070"></i>
						</div>
					</div>
				</div>
			</div>
	</div>
</div>
</div>
</div>
<div ng-if="pagedata.showmore" class="popup">
	<div class="popup-body">
		<div class="popup-bottom" style="background:#f2f2f2;min-height:auto">
			<i class="closed icon icon-cuowu" ng-click="pagedata.showmore=false"></i>
			<div class="fui-icon-group noborder col-5" style="padding:0.5rem">
				<div class="fui-icon-col-sm external" style="margin:0" href="javascript:;" ng-click="pagedata.uppic();">
					<div class="c radius" style="background:#fff;width:2.5rem;height:2.5rem;line-height:2.8rem;margin:auto">
						<i class="icon jinyunicon icon-pic" style="font-size:1rem;color:#63BE72"></i>
					</div>
					<div class="text" style="font-size:0.65rem;color: #666;margin-top:0.3rem">上传图片</div>
				</div>
				<div class="fui-icon-col-sm external" style="margin:0" href="javascript:;" ng-click="pagedata.upfile();">
					<div class="c radius" style="background:#fff;width:2.5rem;height:2.5rem;line-height:2.8rem;margin:auto">
						<i class="icon icon-exl" style="font-size:1rem;color:#63BE72"></i>
					</div>
					<div class="text" style="font-size:0.65rem;color: #666;margin-top:0.3rem">上传文件</div>
				</div>
				<div class="fui-icon-col-sm external" style="margin:0" href="javascript:;" ng-click="pagedata.showqr=true;" ng-if="pagedata.kefu.showqr">
					<div class="c radius" style="background:#fff;width:2.5rem;height:2.5rem;line-height:2.8rem;margin:auto">
						<i class="icon icon-qrcode" style="font-size:1rem;color:#63BE72"></i>
					</div>
					<div class="text" style="font-size:0.65rem;color: #666;margin-top:0.3rem">大夫微信</div>
				</div>
				<div class="fui-icon-col-sm external" style="margin:0" href="javascript:;" ng-click="pagedata.upcommentshow=true;">
					<div class="c radius" style="background:#fff;width:2.5rem;height:2.5rem;line-height:2.8rem;margin:auto">
						<i class="icon icon-haoping" style="font-size:1rem;color:#63BE72"></i>
					</div>
					<div class="text" style="font-size:0.65rem;color: #666;margin-top:0.3rem">大夫评价</div>
				</div>
				<div class="fui-icon-col-sm external" style="margin:0" href="javascript:;" ng-click="pagedata.showfastmsg=true;">
					<div class="c radius" style="background:#fff;width:2.5rem;height:2.5rem;line-height:2.8rem;margin:auto">
						<i class="icon icon-zhifeiji" style="font-size:1rem;color:#63BE72"></i>
					</div>
					<div class="text" style="font-size:0.65rem;color: #666;margin-top:0.3rem">快捷回复</div>
				</div>
			</div>
		</div>
	</div>
</div>
<div ng-if="pagedata.showqr" class="popup">
		<div class="popup-body">
			<div class="popup-bottom">
				<i class="closed icon icon-cuowu" ng-click="pagedata.showqr=false"></i>
				<div class="wap-qrcode-container">
					<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
					<p class="example1">{{pagedata.worker.name}}</p>
					<div class="wap-qrcode-image">
						<img ng-src="{{tomedia(pagedata.worker.kefuqr) || '../core/resource/images/nopic.jpg'}}"/>
					</div>
					<p class="example1">长按二维码关注</p>
				</div>
			</div>
		</div>
</div>
<div ng-if="pagedata.upcommentshow" class="popup">
		<div class="popup-body">
			<div class="popup-bottom">
			<i class="closed icon icon-cuowu" ng-click="pagedata.upcommentshow=false"></i>
				<div class="fui-line" style="width:6rem;margin:0.5rem auto 0 auto">
					<div class="text text-danger" style="background-color:#fafafa" >评价</div>
				</div>
				<div class="weui_cells weui_cells_radio" style="padding:0.5rem">
					<div class="fui-cell-label" style="margin-right:0.8rem;float:left;margin-bottom:0.2rem">
						<input type="radio" class="fui fui-radio fui-radio-danger verify-radio" name="radio2" ng-click="pagedata.post.upcommenttype = 0" value="0"> 好评
					</div>
					<div class="fui-cell-label" style="margin-right:0.8rem;float:left;margin-bottom:0.2rem">
						<input type="radio" class="fui fui-radio fui-radio-danger verify-radio" name="radio2" ng-click="pagedata.post.upcommenttype =1" value="1"> 中评
					</div>
					<div class="fui-cell-label" style="margin-right:0.8rem;float:left;margin-bottom:0.2rem">
						<input type="radio" class="fui fui-radio fui-radio-danger verify-radio" name="radio2" ng-click="pagedata.post.upcommenttype =2" value="2"> 差评
					</div>
				</div>
				<div class="weui_cells weui_cells_form">
					<div class="weui_cell">
						<div class="weui_cell_bd weui_cell_primary">
							<textarea ng-model="pagedata.post.upcommentmsg" class="weui_textarea" placeholder="说点什么吧..." rows="2"></textarea>
							<div class="weui_textarea_counter"><span>0</span>/200</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<div class="mod-check" href="javascript:"  ng-click="pagedata.upcomment()">确认</div>
				</div>
			</div>
		</div>
</div>
<div ng-if="pagedata.showfastmsg" class="popup">
		<div class="popup-body">
			<div class="popup-bottom">
			<i class="closed icon icon-cuowu" ng-click="pagedata.showfastmsg=false"></i>
				<div class="fui-line" style="width:6rem;margin:0.5rem auto 0 auto">
					<div class="text text-danger" style="background-color:#fafafa" >快捷回复</div>
				</div>
				<div ng-if="pagedata.fastmsg.length>0" class="fui-cell-group noborder col-1" style="height:16rem;ovrflow-y:scroll;background: #ffffff;padding-bottom:15px;">
					<a ng-repeat="item in pagedata.fastmsg" class="fui-cell" href="javascript:;" ng-click="pagedata.addchatnew(0,item.title)">
						{{item.title}}
					</a>
				</div>
				<div class="content-empty" ng-show="!pagedata.fastmsg || pagedata.fastmsg.length == 0 ">
					  <i class="icon icon-cry" style="width: 6rem;margin-bottom: 0.5rem;"></i><br/><p style="color: #999;font-size: .75rem">暂时没有快捷方式！</p>
				</div>
			</div>
		</div>
</div>
<!--弹出录音-->
<div ng-if="pagedata.showluyin" class="chat-audio">
	<i class="recording icon jinyunicon icon-shengbo1"></i>
	<p>正在录音中...</p>
</div>
<audio id="openvoice" controls preload="auto" style="display:none;">
	<source src="../core/resource/images/message.mp3"></source>
</audio>
<div ng-include="sys_html('online/_videocall')"></div>
<div ng-include="sys_html('common/_emoji',true)"></div>
<script type="text/javascript">
scope.pagedata.is_backpage=false
var curtype='text';
//滚动加载
scope.scroll(function(){
	setTimeout('getlist()',300);
},true,'svposttext');
function followewm(textimg){
	scope.pagedata.textimg = textimg;
	scope.$evalAsync();
	$('#followewm').modal();
}
var images = {
	localIds: [],
};
var voice = {
	localId: '',
	serverId: ''
};
scope.loading = true;  //状态标记
getlist(1);
function getlist(isnew){
	if(isnew){
		scope.tool.get_list('jy_yiliao/online.index/list/',true,function(res){
			scope.pagedata.list.forEach(function(item){
				if(item.type==0){
					item.msg=decodeURI(item.msg);
				}
			});
			scope.$evalAsync();
			$('#svposttext').animate({scrollTop:100000},300);
		});
	}else{
		scope.tool.get_list('jy_yiliao/online.index/list/','',function(res){
			scope.pagedata.list.forEach(function(item){
				if(item.type==0){
					item.msg=decodeURI(item.msg);
				}
			});
			scope.$evalAsync();
		});
	}
}
function getxml(xmlstring){
			var xmlobject = null;
			try{
				if(window.ActiveXObject){
					xmlobject =new ActiveXObject("Microsoft.XMLDOM");
					xmlobject.async="false";
					xmlobject.loadXML(xmlstring);
				}else{// 用于 Mozilla, Firefox, Opera, 等浏览器的代码：
					var parser=new DOMParser();
					xmlobject =parser.parseFromString(xmlstring,"text/xml");
				}
			}catch(e){alert("您的浏览器不支持");}
			return xmlobject;
}
scope.pagedata.addchatnew=function(type,msg){
	scope.pagedata.newpost=scope.pagedata.post
	scope.pagedata.nowmsg=msg||scope.pagedata.post.msg;
	if(!scope.pagedata.post.type || scope.pagedata.post.type<=0){
		scope.pagedata.nowmsg=encodeURI(scope.pagedata.nowmsg);
		//console.log(scope.pagedata.nowmsg);
		console.log(decodeURI(scope.pagedata.nowmsg));
	}
	if(scope.pagedata.pluginset.liao_bi>0 && scope.pagedata.member.sex==1){
		scope.pagedata.totype1(type,scope.pagedata.nowmsg);
	}else{
		scope.pagedata.addchat(type,scope.pagedata.nowmsg);
	}
}
scope.pagedata.totype1=function(type,msg){
	scope.pagedata.post.msg='';
	scope.pagedata.post.liao_bi=scope.pagedata.pluginset.liao_bi;
	scope.pagedata.newpost.msg2=msg;
	if(scope.pagedata.pluginset.liao_notan!=1){
		scope.confirm({
			'message':'确定要花'+scope.pagedata.pluginset.liao_bi+'个金币发信息吗？',
			'success':function(){
				scope.post_json('jy_yiliao/online.index/check_buy/isbi=1',scope.pagedata.newpost,function(result){
					scope.pagedata.showtype=false
					scope.pagedata.addchat(type,msg);
					return false;
				});
			},
			'fail':function(){}
		});
	}else{
		scope.post_json('jy_yiliao/online.index/check_buy/isbi=1',scope.pagedata.newpost,function(result){
			scope.pagedata.showtype=false
			scope.pagedata.addchat(type,msg);
			return false;
		});
	}
}
scope.pagedata.getmsgkey=0;
scope.pagedata.getmsg={};
scope.pagedata.addchat=function(type,msg) {
	scope.pagedata.post.msg='';
	scope.pagedata.post.type=type?type:0
	scope.pagedata.newpost.msg2=msg;
	console.log(scope.pagedata.newpost);
	//苹果手机键盘归让页面归位
	window.scroll(0,0); //让页面归位
	scope.pagedata.listnew=scope.pagedata.listnew?scope.pagedata.listnew:[];
	scope.post_json('jy_yiliao/online.index/addlog/',scope.pagedata.newpost,function(data){
		console.log(data);
		if(data.log && data.log.id){
			scope.pagedata.post.lastid=data.log.id;
		}
		if(!data.log.type || data.log.type<=0){
			data.log.msg=decodeURI(data.log.msg);
		}
		scope.pagedata.listnew = scope.pagedata.listnew.concat(data.log)
		$('#svposttext').animate({scrollTop:100000},300);
		var key=scope.pagedata.listnew.length;
		if(scope.pagedata.post.type<=0){
			var msg=scope.pagedata.nowmsg;
		}
		scope.pagedata.post.msg='';
		scope.pagedata.showfastmsg=false
		scope.pagedata.showmore=false
		if(data.log && data.log.id){
			if(scope.pagedata.isget){
				if(scope.pagedata.pluginset.iswenda==1){
					scope.message('还有一个问题正在思考中，请稍后提问！','error');
				}
				return false;
			}
			scope.pagedata.isget=true;
			key --
			scope.get('jy_yiliao/online.index/getmsg/msg='+msg+'&tcpid='+scope.pagedata.post.tcpid+'&key='+key+'&workerid='+scope.pagedata.worker.id,function(res){
				console.log('getmsg');console.log(res);
				scope.pagedata.isget=false;
				if(res.log){
					if(!res.log.type || res.log.type<=0){
						res.log.msg=decodeURI(res.log.msg);
						//console.log(res.log.msg);
					}
					if(res.log.id){
						scope.pagedata.post.lastid=res.log.id;
					}
					scope.pagedata.listnew = scope.pagedata.listnew.concat(res.log)
					$('#svposttext').animate({scrollTop:100000},300);
					scope.$evalAsync();
				}
			});
		}
		scope.$evalAsync();
	});	
}
//手机软键盘--搜索
$("body").keydown(function() {
    if (event.keyCode == "13") {
        $('#searchsub').click();
    }
});
scope.pagedata.uppic=function(){
	scope.tool.up_file('image',function(res){
		scope.pagedata.post.image=res;
		scope.pagedata.addchatnew(4,0);
		scope.pagedata.showmore=false
	})
}
scope.pagedata.upfile=function(){
	scope.up_file(function(res){
		scope.pagedata.post.file=res;
		scope.pagedata.addchatnew(7,0);
		scope.pagedata.showmore=false
	},'','other');
}
scope.pagedata.openvoice=function(type){
	var voicetime = 0;
    var openvoice;
	if(type){
		 openvoice = setInterval(() => {
			if(scope.page.action!='online.index'){
				clearInterval(openvoice);
				return false;
			}
			if(!scope.pagedata.post.lastid){
				if(scope.pagedata.list && scope.pagedata.list[0]){
					scope.pagedata.post.lastid=scope.pagedata.list[0].id;
				}
			}
			scope.get('jy_yiliao/online.index/getnewlog/is_worker=1&tcpid='+scope.pagedata.post.tcpid+'&lastid='+scope.pagedata.post.lastid,function(res){
				//console.log(res);
				if(res.log){
					console.log(voicetime);
					voicetime ++;
					$("#openvoice")[0].play();
					if(!res.log.type || res.log.type<=0){
						res.log.msg=decodeURI(res.log.msg);
						//console.log(res.log.msg);
					}
					if(res.log.id){
						scope.pagedata.post.lastid=res.log.id;
					}
					scope.pagedata.listnew=scope.pagedata.listnew?scope.pagedata.listnew:[];
					scope.pagedata.listnew = scope.pagedata.listnew.concat(res.log)
					$('#svposttext').animate({scrollTop:100000},300);
					scope.$evalAsync();
				}
			});
		}, 2000);
		videocall = setInterval(() => {
			scope.get('jy_yiliao/online.get_data/getvideocall/',function(res){
				//console.log('getvideocall');console.log(res);
				if(res.videocall && res.videocall.id){
					scope.pagedata.videocall=res.videocall;
					console.log(voicetime);
					voicetime ++;
					$("#phone_ringing")[0].play();
					scope.pagedata.showvideocall=true;
					clearInterval(videocall);
					scope.$evalAsync();
				}
			});
		}, 3000);
	}
}
scope.pagedata.openvoice(1);
//提交礼物
scope.pagedata.upcomment=function(lpid){
	scope.post_json('jy_yiliao/online.index/upcomment/',scope.pagedata.post,function(res){
		if(res.error!=1){
			scope.pagedata.upcommentshow=false
			scope.pagedata.showmore=false
			scope.$evalAsync();
			scope.message('评价成功！');
		}else{
			scope.message('评价失败！');
		}
	});
}
scope.pagedata.toshiping=function(){
	//scope.message('您暂时没有视频聊天权限！');
	if(scope.pagedata.videocallurl){
		scope.pagedata.newpost=scope.pagedata.post
		scope.pagedata.newpost.type=9,
		scope.pagedata.newpost.msg='发起了视频聊天'
		scope.post_json('jy_yiliao/online.index/addlog/',scope.pagedata.newpost,function(data){
			scope.access_json(scope.pagedata.videocallurl);
		});	
	}else{
		scope.message('您暂时没有视频聊天权限！');
	}
}
require(['jquery'], function($){
	$(".showaudio").on("touchstart",function(event){
		event.preventDefault();
		scope.pagedata.showluyin=true
		scope.$evalAsync();
		START = new Date().getTime();
		recordTimer = setTimeout(function(){
			wx.startRecord({
				success: function(){
					localStorage.rainAllowRecord = 'true';
					$(".chat-audio").removeClass('hide');
					var num=59;
					name = setInterval(function() {
						num--;
						if(num==0){          
							clearInterval(name);
							END = new Date().getTime();
							wx.stopRecord({
								success: function (res) {
									voice.localId = res.localId;
									$('.chat-audio').addClass("hide");
									var audiotime = (END - START);
									scope.pagedata.uploadVoice(audiotime);
								},
								fail: function (res) {
									alert("停止录音动作发生异常", "forbidden");
								}
							});
							$(".showaudio").text('按住  说话');
						}
					}, 1000);
				},
				cancel: function () {
					alert("您拒绝授权录音", "cancel");
				}
			});
		},300);
	});

	//松手结束录音
	$(".showaudio").on('touchend', function(event){
		event.preventDefault();
		END = new Date().getTime();
		scope.pagedata.showluyin=false
		scope.$evalAsync();
		if((END - START) < 1500){
			END = 0;
			START = 0;
			//小于300ms，不录音
			alert("录音时间太短", "forbidden");
			clearTimeout(recordTimer);
			wx.stopRecord();
		}else{
			wx.stopRecord({
				success: function (res) {
					voice.localId = res.localId;
					var audiotime = (END - START);
					scope.pagedata.uploadVoice(audiotime);
			    },
			    fail: function (res) {
					alert("停止录音动作发生异常", "forbidden");
			    }
			});
		}
	});
});
scope.pagedata.startshiping=function(){
	console.log('开始录音！')
	START = new Date().getTime();
	scope.pagedata.showluyin=true
	scope.$evalAsync();
	recordTimer = setTimeout(function(){
			if(!scope.pagedata.showluyin){
				clearTimeout(recordTimer);
				return false;
			}
			wx.startRecord({
				success: function(){
					localStorage.rainAllowRecord = 'true';
					var num=59;
					name = setInterval(function() {
						num--;
						if(num==0){          
							clearInterval(name);
							END = new Date().getTime();
							wx.stopRecord({
								success: function (res) {
									voice.localId = res.localId;
									var audiotime = (END - START);
									scope.pagedata.uploadVoice(audiotime);
								},
								fail: function (res) {
									alert("停止录音动作发生异常", "forbidden");
								}
							});
						}
					}, 1000);
				},
				cancel: function () {
					alert("您拒绝授权录音", "cancel");
				}
			});
	},300);
}
scope.pagedata.endshiping=function(){
		END = new Date().getTime();
		scope.pagedata.showluyin=false
		scope.$evalAsync();
		if((END - START) < 1500){
			END = 0;
			START = 0;
			//小于300ms，不录音
			alert("录音时间太短", "forbidden");
			wx.stopRecord();
		}else{
			wx.stopRecord({
				success: function (res) {
					voice.localId = res.localId;
					var audiotime = (END - START);
					scope.pagedata.uploadVoice(audiotime);
			    },
			    fail: function (res) {
					alert("停止录音动作发生异常", "forbidden");
			    }
			});
		}
}
//上传录音
scope.pagedata.uploadVoice=function(audiotime){
		//调用微信的上传录音接口把本地录音先上传到微信的服务器
		//不过，微信只保留3天，而我们需要长期保存，我们需要把资源从微信服务器下载到自己的服务器
		wx.uploadVoice({
			localId: voice.localId, // 需要上传的音频的本地ID，由stopRecord接口获得
			isShowProgressTips: 1, // 默认为1，显示进度提示
			success: function (res) {
				//把录音在微信服务器上的id（res.serverId）发送到自己的服务器供下载。
				console.log(res);
				scope.pagedata.post.audiotime=audiotime
				scope.pagedata.addchat(3,res.serverId);
			}
		});
}
scope.pagedata.playaudio=function(serverid,id){
		wx.downloadVoice({
			serverId: serverid,
			success: function (res) {
				console.log(res)
				wx.playVoice({
					localId: res.localId,
				});
				scope.post_json('jy_yiliao/online.index/playaudio/',{id:id},function(red){});
			},
			fail: function (res) {
				scope.message(res.errMsg,'error');
			}
		});
}
</script>